 <?php
	print("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?> \n");
	print("<Result>\n");
	print("<DID>");
	if(!isset($_GET["name"]) || !isset($_GET["CID"]))
	{
		print("</DID>\n");
		print("</Result> \n");
		return;
	}
	$db = mysql_connect("localhost","root","root");
    mysql_select_db("brainway");
	$query = "insert into datasource_name (name, CID) values (\"".$_GET["name"]."\",\"".$_GET["CID"]."\")";
    $result = mysql_query($query);
    if($result==null)       //name has existed
    {
        print("</DID>\n");
	print("</Result> \n");
	return;
    }
    
    $query = "select max(DID) DID from datasource_name";
    $result = mysql_query($query);
    $row = mysql_fetch_array($result);
    print($row["DID"]);
    print("</DID> \n");
    print("<CID>".$_GET["CID"]."</CID> \n");
    print("</Result> \n");
?>